import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// import styleImport, { VantResolve } from 'vite-plugin-style-import'
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from 'unplugin-vue-components/resolvers';
// import { viteMockServer } from 'vite-plugin-mock'
import postCssPxToRem from 'postcss-pxtorem'

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [vue(),
  Components({
    resolvers: [VantResolver()],
  }),
//   styleImport({
//     resolves: [VantResolve()],
//   }),
    // 
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  css: {
    postcss: {
      plugins:
        [
          postCssPxToRem({
            rootValue: 37.5,
            propList: ['*']
          }),
        ],
    },
    },
    server: {
        proxy: {
          "/api": {
            target: "http://127.0.0.1:3512",
            changeOrigin: true,
            rewrite: (path) => path.replace(/^\/api/, ""),
          },
        },
      },
})
